//
// Created by ziya on 22-9-13.
//

#ifndef ZIYA_ELFREADER_FINAL_BUFFER_H
#define ZIYA_ELFREADER_FINAL_BUFFER_H

#include "../common.h"

typedef struct buffer {
    char*   filepath;
    uint    filesize;
    char*   data;
    uint    off;
} __attribute__((packed)) buffer_t;

buffer_t* buffer_create(const char* filepath);

u_char buffer_read1(buffer_t* buffer);
u_short buffer_read2(buffer_t* buffer);
u_int32_t buffer_read4(buffer_t* buffer);
u_int64_t buffer_read8(buffer_t* buffer);

void buffer_copy(buffer_t* buffer, char* dest, size_t size);

void buffer_reset(buffer_t* buffer);

#endif //ZIYA_ELFREADER_FINAL_BUFFER_H
